package demo1;
//静态内部类
class OuterClass2 {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;

    //静态内部类是不依靠外部类的
    static class InnerClass {
        public int data4 = 4;
        private int data5 = 5;
        public static int date6 = 6;

        public void test() {
//            System.out.println(data1);//err
            OuterClass2 outerClass2 = new OuterClass2();
            System.out.println(outerClass2.data1);//right
            System.out.println("内部类的test方法");
        }
    }
}
public class Test3 {
    public static void main(String[] args) {
                                                //静态类需要类的引用
        OuterClass2.InnerClass innerClass = new OuterClass2.InnerClass();
        innerClass.test();
    }
}
/**
 * 1.如何获取 静态内部类对象
 OuterClass2.InnerClass innerClass = new OuterClass2.InnerClass();
 * 2.如何在静态内部类当中 访问外部类中的非静态的数据成员
 * OuterClass2 outerClass2 = new OuterClass2();
 * System.out.println(outerClass2.data1);
 */
